package thread;

import java.util.Scanner;

/**
 * @Author liangzai
 * @Description:
 */
public class Demo3 {
    private static int flag = 0;

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(()->{
            while (flag == 0) {
                try {
                    Thread.sleep(1);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
        Thread t2 = new Thread(()->{
            Scanner scanner = new Scanner(System.in);
            System.out.print("flag=");
            flag = scanner.nextInt();
        });

        t1.start();
        t2.start();
        t1.join();
        t2.join();
        //System.out.println("main结束！");
    }
}
